Return a boolean indicating whether we could do the requested move.
authorMatthias Clasen <mclasen@redhat.com>
Sun, 28 Nov 2004 06:06:57 +0000 (06:06 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sun, 28 Nov 2004 06:06:57 +0000 (06:06 +0000)
2004-11-28  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtktextview.c (gtk_text_view_move_iter_by_lines): Return
a boolean indicating whether we could do the requested move.
(gtk_text_view_move_cursor_internal): For GTK_MOVEMENT_DISPLAY_LINES,
move to the beginning/end of the line if we're on the first/last
line.  (#155891, Paolo Borelli)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktextlayout.c
gtk/gtktextview.c

index 199d702fa339ffc3268de7d36daf7144d53b4f57..2be3dcbc6a775b2bfbe035f9cdd1e9b3830d1799 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-11-28  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_move_iter_by_lines): Return
+       a boolean indicating whether we could do the requested move.
+       (gtk_text_view_move_cursor_internal): For GTK_MOVEMENT_DISPLAY_LINES,
+       move to the beginning/end of the line if we're on the first/last
+       line.  (#155891, Paolo Borelli)
+
+       * gtk/gtktextlayout.c (gtk_text_layout_move_iter_to_previous_line): 
+       Don't move the iter and return FALSE if trying to move up from
+       the first line.
+
 2004-11-28  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c (closure_accel_activate): Don't claim to have
index 199d702fa339ffc3268de7d36daf7144d53b4f57..2be3dcbc6a775b2bfbe035f9cdd1e9b3830d1799 100644 (file)
@@ -1,3 +1,15 @@
+2004-11-28  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_move_iter_by_lines): Return
+       a boolean indicating whether we could do the requested move.
+       (gtk_text_view_move_cursor_internal): For GTK_MOVEMENT_DISPLAY_LINES,
+       move to the beginning/end of the line if we're on the first/last
+       line.  (#155891, Paolo Borelli)
+
+       * gtk/gtktextlayout.c (gtk_text_layout_move_iter_to_previous_line): 
+       Don't move the iter and return FALSE if trying to move up from
+       the first line.
+
 2004-11-28  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c (closure_accel_activate): Don't claim to have
index 199d702fa339ffc3268de7d36daf7144d53b4f57..2be3dcbc6a775b2bfbe035f9cdd1e9b3830d1799 100644 (file)
@@ -1,3 +1,15 @@
+2004-11-28  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_move_iter_by_lines): Return
+       a boolean indicating whether we could do the requested move.
+       (gtk_text_view_move_cursor_internal): For GTK_MOVEMENT_DISPLAY_LINES,
+       move to the beginning/end of the line if we're on the first/last
+       line.  (#155891, Paolo Borelli)
+
+       * gtk/gtktextlayout.c (gtk_text_layout_move_iter_to_previous_line): 
+       Don't move the iter and return FALSE if trying to move up from
+       the first line.
+
 2004-11-28  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c (closure_accel_activate): Don't claim to have
index 199d702fa339ffc3268de7d36daf7144d53b4f57..2be3dcbc6a775b2bfbe035f9cdd1e9b3830d1799 100644 (file)
@@ -1,3 +1,15 @@
+2004-11-28  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_move_iter_by_lines): Return
+       a boolean indicating whether we could do the requested move.
+       (gtk_text_view_move_cursor_internal): For GTK_MOVEMENT_DISPLAY_LINES,
+       move to the beginning/end of the line if we're on the first/last
+       line.  (#155891, Paolo Borelli)
+
+       * gtk/gtktextlayout.c (gtk_text_layout_move_iter_to_previous_line): 
+       Don't move the iter and return FALSE if trying to move up from
+       the first line.
+
 2004-11-28  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c (closure_accel_activate): Don't claim to have
index 7c5dff55f56967d009e0aa65ab6b4af581d12993..56d100d0a04ad106539440bc0e18a9866d01bb35 100644 (file)
@@ -2752,12 +2752,17 @@ gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
     {
       line_byte = layout_line->start_index + layout_line->length;
     }
-  
+
   if (line_byte < layout_line->length || !tmp_list->next) /* first line of paragraph */
     {
       GtkTextLine *prev_line;
 
       prev_line = _gtk_text_line_previous (line);
+
+      /* first line of the whole buffer, do not move the iter and return FALSE */
+      if (prev_line == NULL)
+        goto out;
+
       while (prev_line)
         {
           gtk_text_layout_free_line_display (layout, display);
@@ -2776,9 +2781,6 @@ gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
 
           prev_line = _gtk_text_line_previous (prev_line);
         }
-
-      if (prev_line == NULL)
-       line_display_index_to_iter (layout, display, iter, 0, 0);
     }
   else
     {
index 8323491cd56480e39d34b5748ba6696146f28231..17fc6981588e14e09eefce9de8c8bea12babbdcd 100644 (file)
@@ -4532,22 +4532,26 @@ gtk_text_view_pend_cursor_blink(GtkTextView *text_view)
  * Key binding handlers
  */
 
-static void
+static gboolean
 gtk_text_view_move_iter_by_lines (GtkTextView *text_view,
                                   GtkTextIter *newplace,
                                   gint         count)
 {
+  gboolean ret = TRUE;
+
   while (count < 0)
     {
-      gtk_text_layout_move_iter_to_previous_line (text_view->layout, newplace);
+      ret = gtk_text_layout_move_iter_to_previous_line (text_view->layout, newplace);
       count++;
     }
 
   while (count > 0)
     {
-      gtk_text_layout_move_iter_to_next_line (text_view->layout, newplace);
+      ret = gtk_text_layout_move_iter_to_next_line (text_view->layout, newplace);
       count--;
     }
+
+  return ret;
 }
 
 static void
@@ -4658,8 +4662,21 @@ gtk_text_view_move_cursor_internal (GtkTextView     *text_view,
       break;
 
     case GTK_MOVEMENT_DISPLAY_LINES:
-      gtk_text_view_move_iter_by_lines (text_view, &newplace, count);
-      gtk_text_layout_move_iter_to_x (text_view->layout, &newplace, cursor_x_pos);
+      if (count < 0)
+      {
+        if (gtk_text_view_move_iter_by_lines (text_view, &newplace, count))
+          gtk_text_layout_move_iter_to_x (text_view->layout, &newplace, cursor_x_pos);
+        else
+          /* we currently do not have a backward_to_start, use offset */
+          gtk_text_iter_set_offset (&newplace, 0);
+      }
+      if (count > 0)
+      {
+        if (gtk_text_view_move_iter_by_lines (text_view, &newplace, count))
+          gtk_text_layout_move_iter_to_x (text_view->layout, &newplace, cursor_x_pos);
+        else
+          gtk_text_iter_forward_to_end (&newplace);
+      }
       break;
 
     case GTK_MOVEMENT_DISPLAY_LINE_ENDS: